<?php

namespace app\data\controller\shop;

use app\data\service\GoodsService;
use think\admin\Controller;

/**
 * 月返息统计
 * Class Portal
 * @package app\data\controller\total
 */
class Month extends Controller
{
    /**
     * 月返息统计
     * @auth true
     * @menu true
     */
    public function index()
    {
        $where = [];

        $nextMonth = date('Y-m', strtotime(getPurMonth(date('Y-m'),1)));

        $where[] = ['month', '=', $nextMonth];

        //下月应返利息总额
        $this->total   = $this->app->db->name('shop_order_return_rate_log')->where($where)->sum('money');


        if (input('isall') == 1){
            $this->_query('shop_order_return_rate_log')->alias('orr')
                ->leftJoin('shop_order so', 'so.id = orr.order_id')
                ->field('orr.id m_id,orr.month,orr.money as month_money,orr.status m_status,so.*')
                ->where($where)->order('orr.create_at desc,orr.id desc')->select();

            return;
        }


        $this->_query('shop_order_return_rate_log')->alias('orr')
            ->leftJoin('shop_order so', 'so.id = orr.order_id')
            ->field('orr.id m_id,orr.month,orr.money as month_money,orr.status m_status,so.*')
            ->where($where)->order('orr.create_at desc,orr.id desc')->page();
    }

    public function _index_page_filter(&$data){



    }

}